package com.zcx.qshop.adapter;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import android.widget.TextView;

import com.zcx.helper.bound.BoundView;
import com.zcx.helper.bound.BoundViewHelper;
import com.zcx.helper.view.rebound.ReboundLayout;
import com.zcx.helper.view.rebound.ReboundListView;
import com.zcx.helper.widget.AppReboundAdapter;
import com.zcx.qshop.R;
import com.zcx.qshop.QSApplication;
import com.zcx.qshop.conn.JsonSchoolAsyGet;

import java.util.List;

/**
 * Created by Administrator on 2015/8/22 0022.
 */
public class  SchoolAdapter extends AppReboundAdapter<JsonSchoolAsyGet.Info.School> {

    private LayoutInflater layoutInflater;

    public SchoolAdapter(Context context, ReboundListView reboundListView, List<JsonSchoolAsyGet.Info.School> objects) {

        super(context, reboundListView, objects);

        layoutInflater = ((Activity)context).getLayoutInflater();

    }

    @Override
    public ReboundLayout getReboundLayout(int i, ReboundLayout reboundLayout, ViewGroup viewGroup) {

        ViewHolder viewHolder;

        if(reboundLayout == null){

            reboundLayout = (ReboundLayout) BoundViewHelper.boundView(viewHolder = new ViewHolder(), QSApplication.ScaleScreenHelper.loadView((ViewGroup) layoutInflater.inflate(R.layout.item_school, null)));

            reboundLayout.setTag(viewHolder);

        }else{

            viewHolder = (ViewHolder) reboundLayout.getTag();

        }

        viewHolder.school.setText(getItem(i).name);

        return reboundLayout;

    }

    private class ViewHolder{

        @BoundView(R.id.item_school_school) public TextView school;

    }

}
